connect:
	cargo run -- device connect 192.168.1.7:43241 ybd_mtt
	
connect2:
	cargo run -- device connect 192.168.1.3:39385

find:
	cargo run -- package find meituan

show:
	cargo run -- package show current-focus

screenshotex:
	cargo run -- package screenshotex -n=10 -o=tmp_ocr com.sankuai.meituan.takeoutnew

screenshotex2:
	cargo run -- package screenshotex -n=10 -o=tmp_ocr com.sankuai.meituan.takeoutnew

capture:
	cargo run -- ybd_mtt screen capture -n 1

capture_old:
	cargo run -- ybd_mtt screen capture-old -n 1

capture_as_train:
	cargo run -- ybd_mtt screen capture -n 5 --train

capture_as_train_old:
	cargo run -- ybd_mtt screen capture-old -n 5 --train

exec-search:
	cargo run -- mtt1 exec search -P home -n 5  牛肉粉丝

exec-parse:
	cargo run -- mtt1 exec parse mtt1/captures/牛肉粉丝/Screenshot_1679283036269

train-init:
	cargo run -- ybd_mtt train init --lang zheng --font mtt

train-convert-sample:
	cargo run -- ybd_mtt train convert-sample --lang zheng --font mtt  captures/Train/1676948389369

config-home:
	cargo run -- mtt1 config set home -t "go_top=137, 2290" -t "into_search=200,300" -t "do_search=964,148"

config-search:
	cargo run -- mtt1 config set search \
	-t "back=60,145" \
	-c "crop=190, 420, 890, 1980" \
	-c "swipe_from = 600, 2000" \
	-c "swipe_to = 600, 660" \
	-c "swipe_duration=2000" \
	-c "segment_border_color=245, 245, 246" \
	-c "segment_sample_size=10" \
	-c "segment_left_padding=40" \
	-c "segment_right_padding=180" \
	-c "segment_left_crop=0" \
	-c "segment_right_crop=0" \
	-c "segment_min_height=600" \
	-c "segment_max_height=999999"

config:
	cargo run -- ybd_mtt config set home -s "click_to_point=0,0" -s "crop=355, 355, 700, 1820" -s "swipe_to_start = 600, 2155, 600, 1405" -s "swipe_per_page = 600, 2155, 600, 1105"

convert:
	cargo run -- magick convert  output.tiff tmp_ocr/*.png ybd_mtt/captures/Train/1676948389369/*.png

new:
	cargo run -- new

r:
	cargo run -- image recognition tmp_ocr/test.png

r2:
	cargo run -- image recognition-ex  ybd_mtt/captures/Screenshot/1678177119557/0.png

r3:
	cargo run -- image recognition-ex  --boudary-color 245,245,246,255 --sampling-size 10 --right-padding 180 --min-height 600 mtt1/captures/牛肉/Screenshot_1678956127417/0.png

b:
	cargo run -- image binarization tmp_ocr/sc_1.png
c:
	cargo run -- image crop tmp_ocr/sc_1.png

## oem=2必须使用tessdata里的chi_sim,不能使用tessdata_best里的chi_sim

##当使用best目录中的新模型时，tesseract只支持基于LSTM的OCR引擎，而legacy引擎是不支持这些文件的。因此，当tesseract的oem模式选为0或2时，是不支持best目录中的新模型的。
##可以用如下命令来检测文字方向及所用语言：

##
## 对于chi_sim+eng
te31:
	tesseract ybd_mtt/captures/Train/1676948389369/0.png zheng_psm3_oem1 -l chi_sim+eng --psm 3 --oem 1  --dpi 440
## psm=6 对于chi_sim+eng
te61:
	tesseract ybd_mtt/captures/Train/1676948389369/0.png zheng_psm6_oem1 -l chi_sim+eng --psm 6 --oem 1  --dpi 440

# +eng会失败
te32:
	tesseract ybd_mtt/captures/Train/1676948389369/0.png zheng_psm3_oem2 -l chi_sim+eng --psm 3 --oem 2  --dpi 440

# oem=3默认
te33:
	tesseract ybd_mtt/captures/Train/1676948389369/0.png zheng_psm3_oem3 -l chi_sim+eng --psm 3 --oem 3  --dpi 440

## 对于chi_sim3+eng
t3e31:
	tesseract ybd_mtt/captures/Train/1676948389369/0.png zheng3_psm3_oem1 -l chi_sim3+eng --psm 3 --oem 1  --dpi 440
# oem=2(Legacy + LSTM engines) font=chi_sim3会失败
t3e32:
	tesseract ybd_mtt/captures/Train/1676948389369/0.png zheng3_psm3_oem2 -l chi_sim3+eng --psm 3 --oem 2  --dpi 440
t3e33:
	tesseract ybd_mtt/captures/Train/1676948389369/0.png zheng3_psm3_oem3 -l chi_sim3+eng --psm 3 --oem 3  --dpi 440

t1:
	tesseract ybd_mtt/trains/t1/chi_sim3.t1.exp0.png t1_psm13_oem1 -l chi_sim_t1 --psm 13 --oem 1 --dpi 300 

chi_sim3:
	tesseract  ybd_mtt/trains/mtt-0/0-1_0_204_725_56.png mtt-output-chi_sim3 -l chi_sim3  --psm 13 --oem 1 --dpi 300

mtt0:
	tesseract  ybd_mtt/trains/mtt-0/0-1_0_204_725_56.png mtt-output-chi_sim_mtt0 -l chi_sim_mtt0  --psm 13 --oem 1 --dpi 300

#生成box
train-mtt-1:
	tesseract ybd_mtt/trains/mtt-0/chi_sim3.mtt.exp0.tif ybd_mtt/trains/mtt-0/chi_sim3.mtt.exp0 -l chi_sim3 --dpi 300 --psm 13 batch.nochop lstmbox

#生成lstm
train-mtt-2:
	tesseract  ybd_mtt/trains/mtt-0/chi_sim3.mtt.exp0.tif ybd_mtt/trains/mtt-0/chi_sim3.mtt.exp0 -l chi_sim3 --dpi 300 --psm 13 lstm.train

#训练
train-mtt-3:
	lstmtraining  --debug_interval -5  --max_iterations 500  --target_error_rate 0.1  --continue_from=train-common/chi_sim3.lstm  --model_output=ybd_mtt/trains/mtt-0/exp0_out/mod_out  --train_listfile=ybd_mtt/trains/mtt-0/chi_sim3.mtt.exp0.list.txt  --traineddata=train-common/chi_sim3.traineddata

#合并训练数据
train-mtt-4:
	lstmtraining  --stop_training  --traineddata=train-common/chi_sim3.traineddata  --continue_from=ybd_mtt/trains/mtt-0/exp0_out/mod_out_checkpoint  --model_output=ybd_mtt/trains/mtt-0/exp0_out/chi_sim_mtt0.traineddata

screenrecord:
	adb exec-out "screenrecord --bit-rate=32m --output-format=h264 --size 1080x2400 --time-limit 30 -" > test2.mp4